package t1002;


import java.util.Scanner;

/**
 * 姓名： 张东升
 * 日期: 2025年03月2025/3/24日
 *
 */
public class Main {

    public static int intLength;
    public static int charLength;


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] ints = null;
        char[] chars = null;
        ints = createIntArray(scanner);
        chars = createCharArray(scanner);
        System.out.println("The length:" + intLength);
        sort(ints, intLength);
        System.out.println("The length:" + charLength);
        sort(chars, charLength);

    }

    public static int[] createIntArray(Scanner scanner) {
        int count = scanner.nextInt();
        int[] ints = new int[count];
        for (int i = 0; i < count; i++) {
            ints[i] = scanner.nextInt();
        }
        intLength = count;
        return ints;
    }


    public static char[] createCharArray(Scanner scanner) {
        int count = scanner.nextInt();
        char[] chars = new char[count];
        char[] charArray = scanner.nextLine().toCharArray();
        int tempCount = count;
        for (int i = 1; i < charArray.length; i++) {
            chars[--tempCount] = charArray[i];
        }

        charLength = count;
        return chars;
    }


    public static void sort(int[] ints, int count) {
        for (int i = 0; i < count; i++) {
            for (int j = i + 1; j < count; j++) {
                if (ints[i] > ints[j]) {
                    int temp = ints[i];
                    ints[i] = ints[j];
                    ints[j] = temp;
                }
            }
        }

        System.out.println("The elements:");
        for (int i = 0; i < count; i++) {
            System.out.printf("%d ", ints[i]);
        }

        System.out.println();
    }

    public static void sort(char[] chars, int count) {
        for (int i = 0; i < count; i++) {
            for (int j = i + 1; j < count; j++) {
                if (chars[i] > chars[j]) {
                    char temp = chars[i];
                    chars[i] = chars[j];
                    chars[j] = temp;
                }
            }
        }

        System.out.println("The elements:");
        for (int i = 0; i < count; i++) {
            System.out.printf("%c ", chars[i]);
        }

        System.out.println();
    }
}




